Image Shaped Form Example Readme!

 

Regardments to this Example
  To execute this example you will need the COMDLG32.OCX file, that contains the support for the Open File and Colour Picker windows used by the program.

Even so, you only need it to see this example and not if you want to create your own Image Shaped Forms!

What your going to learn with this Example
 
  • How to create your own Image Shaped Forms.
  • How to use some of the options provided by the Microsoft Common Dialog Control.
  • How to create a Form that can be moved from any part of it (not just the Title Bar), using some API functions.
Creating your own Image Shaped Forms
  If you want to create your own Image Shaped Forms then you just need to add the Module1.bas file to your project and follow these step-by-step instructions for each Shaped Form!

After adding Module1.bas file to your project, set the Background Picture Property of the future shaped form and set it's BorderStyle Property to "0 - None". Remember: the smaller the image, the faster it is scanned and the faster is the shape created.

Attention: Be sure to set the forms dimensions equal or bigger that of the Background Picture dimensions. If you don't, the shape won't be right.

Now add the following line to the declarations (the top) of your form:

Private hRgn as Long

Then add the following lines to the Form_Load() event:

hRgn = GetBitmapRegion(Me.Picture, TransparentColor)
SetWindowRgn Me.hwnd, hRgn,
True

Attention: remember to replace the TransparentColor variable on the previous line by the colour that will be "removed" from the Image, creating the new Shape.

Finally, add the following line to the Form_Unload() event:

DeleteObject hRgn

Attention: the previous line of code MUST be executed before closing the form; it will allow VB to free the allocated memory by the created Shape.

If you also want to freely move your Image Shaped Form from any point of it (since it has no Title Bar that would allow it to be moved), add the following lines to the Form_MouseDown() event:

ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&

Programmed by Pedro Lamas
Copyright ©1997-1999 Underground Software

Home-Page (Dedicated to VB): www.terravista.pt/portosanto/3723/
E-Mail:
sniper@hotpop.com